package com.iot08.api.controller;

import com.iot08.api.controller.base.BaseController;
import com.iot08.api.service.DeviceCostFlowService;
import com.iot08.api.service.DeviceDataFlowService;
import com.iot08.common.utils.response.ResponseMap;
import com.iot08.api.vo.request.DelDeviceCostFlowReqVO;
import com.iot08.api.vo.request.TypeParamReqVO;
import com.iot08.api.vo.request.SetDeviceDataFlowReqVO;
import com.iot08.api.vo.request.base.BaseAccountReqVO;
import org.springframework.validation.BindingResult;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @version 1.0
 * @Description: 流量相关接口
 * @time: 2020/12/15 10:22
 * @author: Rock
 */
@RestController
@RequestMapping("getway")
public class TrafficController extends BaseController {

    @Resource
    private DeviceCostFlowService deviceCostFlowService;
    @Resource
    private DeviceDataFlowService deviceDataFlowService;

    /**
     * 查询话费流量
     *
     * @param imei
     * @param vo
     * @param bindingResult
     * @time: 2020/12/15 10:28
     * @author: Rock
     * @version 1.0
     */
    @PostMapping("/inquire/{imei}")
    public ResponseMap inquireTraffic(@PathVariable("imei") String imei,
                                      @Validated TypeParamReqVO vo, BindingResult bindingResult) {
        return deviceCostFlowService.inquireTraffic(imei, vo);
    }

    /**
     * 查询话费流量的记录
     *
     * @param imei
     * @param vo
     * @param bindingResult
     * @time: 2020/12/15 11:24
     * @author: Rock
     * @version 1.0
     */
    @GetMapping("/inquire/{imei}")
    public ResponseMap listDeviceCostFlow(@PathVariable("imei") String imei,
                                          @Validated BaseAccountReqVO vo, BindingResult bindingResult) {
        return deviceCostFlowService.list(imei, vo);
    }

    /**
     * 删除话费流量的记录
     *
     * @param imei
     * @param vo
     * @param bindingResult
     * @time: 2020/12/15 11:29
     * @author: Rock
     * @version 1.0
     */
    @DeleteMapping("/inquire/{imei}")
    public ResponseMap delDeviceCostFlow(@PathVariable("imei") String imei,
                                         @Validated DelDeviceCostFlowReqVO vo, BindingResult bindingResult) {
        return deviceCostFlowService.del(imei, vo);
    }

    /**
     * 获取流量设置数据
     *
     * @param imei
     * @param vo
     * @param bindingResult
     * @time: 2021/1/13 10:37
     * @author: Rock
     * @version 1.0
     */
    @GetMapping("/dataflow-monitoring/{imei}")
    public ResponseMap getDeviceDataFlow(@PathVariable("imei") String imei,
                                         @Validated BaseAccountReqVO vo, BindingResult bindingResult) {
        return deviceDataFlowService.getInfo(imei, vo);
    }

    /**
     * 设置流量设置数据
     *
     * @param imei
     * @param vo
     * @param bindingResult
     * @time: 2020/12/16 15:07
     * @author: Rock
     * @version 1.0
     */
    @PostMapping("/dataflow-monitoring/{imei}")
    public ResponseMap setDeviceDataFlow(@PathVariable("imei") String imei,
                                         @Validated SetDeviceDataFlowReqVO vo,
                                         BindingResult bindingResult) {
        return deviceDataFlowService.setDeviceDataFlow(imei, vo);
    }

}
